#pragma once

namespace hawking {
namespace indexlib {

enum class Status {
    OK,

    /*  for business code*/
    InitFailure,
    
    Corruption,
    IOError,
    NoMem,
    Abort,
    Unknown,
    ConfigError,
    InvalidArgs,
    InternalError,
    OutOfRange,
    Eof,

    NeedDump,
    Unimplement,
    Uninitialize,
    NotFound,
    Expired,
    Deleted,
    Exist,
    Sealed,
    ParseError,
    NotSupport
};

template<class ValueType>
struct ReturnValue {
    Status status;
    ValueType value;

    ReturnValue(Status s, ValueType v) : status(s), value(v) {}

    const ValueType& Value() const {
        return value;
    }
    ValueType&& MovableValue() {
        return std::move(value);
    }

    bool OK() const {
        return status == Status::OK;
    }

    Status Code() const {
        return status;
    }
};

}
}